/**
 * 工具类
 */
export default class Utility {
  /**
   * 密文
   */
  static pass_PublicKey=`MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQkFYxH2P/FgBc/tu3XVZjNsHchLRhXqx96qONILVnGeCbg92ngM+1hETCXWzWHPFmIaNrBGWCXnbQKCwn2OZZ14tfBC7YWg6pWQrW2QN8aMoxCA//498J/HLcMsPhr2idAoI8ASNAWF/Nw0a8HB27FKMb3lSBTBUd45EkrmzaJQIDAQAB`
 
 




  /**
   *
   * @param {key} key   想要从链接获取参数的key
   * @param {url} Url   整个🔗
   */
  static getSearchString(key, Url) {
    var str = window.location.search;
    str = str.substring(1, str.length); // 获取URL中?之后的字符（去掉第一位的问号）
    // 以&分隔字符串，获得类似name=xiaoli这样的元素数组
    var arr = str.split("&");
    var obj = new Object();

    // 将每一个数组元素以=分隔并赋给obj对象
    for (var i = 0; i < arr.length; i++) {
      var tmp_arr = arr[i].split("=");
      obj[decodeURIComponent(tmp_arr[0])] = decodeURIComponent(tmp_arr[1]);
    }
    return obj[key];
  }

  /**
   * 对参数进行排序
   * 参数对象  keyObj
   */
  static parmaSort(keyObj) {
    var keyArr = [];
    for (var key in keyObj) {
      keyArr.push(key);
    }
    var reaKryArr = keyArr.sort();
    var newArrStr = "";
    for (var i = 0; i < keyArr.length; i++) {
      newArrStr += reaKryArr[i] + "=" + keyObj[reaKryArr[i]] + "&";
    }
    var str = newArrStr.substr(0, newArrStr.length - 1);
    return str;
  }
}
